package zhoug.common.eventbus;


import java.io.Serializable;


/**
 * EventBus 消息事件
 *
 * @Author HK-LJJ
 * @Date 2020/3/13
 * @Description
 */
public class EventMessage implements Serializable {
    private int type;//事件类型
    private String message;//消息
    private Serializable data;//数据

    public EventMessage() {
    }

    public EventMessage( int type) {
        this.type = type;
    }

    public EventMessage(int type, String message) {
        this.type = type;
        this.message = message;
    }

    public EventMessage(int type, String message, Serializable data) {
        this.type = type;
        this.message = message;
        this.data = data;
    }

    public int getType() {
        return type;
    }

    public void setType( int type) {
        this.type = type;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Serializable getData() {
        return data;
    }

    public void setData(Serializable data) {
        this.data = data;
    }

    /**
     * 是否匹配Type
     * @param types
     * @return
     */
    public boolean matchType(int... types){
        if(types != null){
            for(int t:types){
                if(t==type){
                    return true;
                }
            }
        }
        return false;
    }

}
